package com.blog.web.manage;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.blog.constant.Constants;
import com.blog.pojo.Member;
import com.blog.pojo.Technique;
import com.blog.service.MemberService;

/** 
 * @author ant 
 * @date 创建时间：2017年8月24日 下午4:56:16  
 */
@Controller
@RequestMapping("/manage")
public class MemberViewController {
	
	@Autowired
	private MemberService memberService;
	
	private final String MEMBER = "manage/about";
	
	@RequestMapping("/view/information")
	public String goToInformation(Model model) {
		Member member =memberService.findMemberByMemberId(Constants.ADMIN_ID);
		model.addAttribute("member", member);
		return MEMBER + "/person_information";
	}
	
	@RequestMapping("/view/project")
	public String goToProject() {	
		return MEMBER + "/person_information";
	}
	
	@RequestMapping("/view/technique")
	public String goToTechnique() {	
		return MEMBER + "/technique";
	}
	
	@RequestMapping("techniqueEdit")
	public String goToTechniqueEdit(String act,Integer techniqueId,Model model) {
		if (StringUtils.equals("edit", act)) {
			Technique technique = memberService.getTechniqueByTechniqueId(techniqueId);
			model.addAttribute("technique", technique);
			model.addAttribute("title", "更新技能");
		} else {
			model.addAttribute("technique", new Technique());
			model.addAttribute("title", "添加技能");
		}
		model.addAttribute("act", act);
		return MEMBER+"/techniqueEdit";	
	}

}
